package edu.hawaii.duedates.configuration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;


/**
 * Tests the basic functionality of a DueDatesConfiguration object.
 * 
 * @author Tyler Wolff
 *
 */
public class TestDueDatesConfiguration {

  /**
   * Tests basic object creation and smtp set/get methods.
   */
  @Test
  public void testDueDatesConfiguration() {
    
    DueDatesConfiguration test = new DueDatesConfiguration();
    assertNotNull("tests object creation", test);
    test.setSmtpServer("mail.hawaii.edu");
    assertEquals("tests getSmptServer", "mail.hawaii.edu", test.getSmtpServer());
  }
  
  /**
   * Tests user addition and getUser method.
   */
  @Test
  public void testAddUser() {
    DueDatesConfiguration tester = new DueDatesConfiguration();
    User testUser = new User("Name", "wolff@hawaii.edu", "password");  
    tester.addUser(testUser);
    tester.addUser(testUser);
    
    // check validateUser method for wolff@hawaii.edu
    assertNotNull("find wolff@hawaii.edu", tester.validateUser("wolff@hawaii.edu", "password"));
    assertNull("find unknown user", tester.validateUser("unknown@hawaii.edu", "password"));
  }
}
